Jeremy Nwachukwu // Field notes

How Understanding LLM Internals Saves Time and Money When Building AI Agents

125 views June 7, 2026

Why Understanding AI Models Matters Before Building AI Agents

You cannot build a car well if you do not understand what an engine does. In the same way, it is hard to build good AI agents if you do not understand the models behind them.

A lot of people can call ChatGPT, Gemini, or Claude through an API. Far fewer can explain:

  • why a model feels smart in one moment and dumb in another
  • why some models feel slow
  • why hardware affects performance
  • why prompting strategy changes from model to model
  • why a bad model choice can waste money

If you want to build useful AI agents, you should understand the basics of how AI models work.

1. Two Common Ways Models Generate Output

Before talking about agents, it helps to understand two major generation strategies:

  1. Autoregressive generation
  2. Diffusion-based generation

Important: these are generation methods, not necessarily the entire architecture.

Autoregressive models

Autoregressive models generate text one token at a time, usually from left to right.

That is how many popular language models work. The model looks at the existing context, predicts the next token, then repeats the process.

This is why latency matters: if a model must generate a long answer token by token, every extra step adds time.

Diffusion models

Diffusion models are best known in image generation, where they start from noise and gradually refine it into a coherent output.

Diffusion-style language models also exist, though they are much rarer in public use than autoregressive models. A current public example is Inception Labs’ Mercury family, which the company describes as a diffusion large language model available through a public API and playground.[2]

So the basic idea is:

  • Autoregressive: predict the next token step by step
  • Diffusion: iteratively refine a noisy draft toward a final output

What this does not mean

It is tempting to say “AI is just gambling,” but that is a little too simplistic.

A better way to say it is:

  • AI models are probabilistic systems
  • they generate outputs based on learned distributions
  • they can behave differently depending on settings like temperature, context, tools, and sampling strategy

So yes, there is uncertainty. But it is not random in the same way as rolling a fair die.

2. Transformers: the Core Architecture Behind Modern LLMs

A major turning point in AI came from the 2017 paper:

Attention Is All You Need[1]

That paper introduced the transformer architecture, which became the foundation for many modern models.

This is also where the “T” in GPT comes from:

  • GPT = Generative Pretrained Transformer

Original transformer vs modern LLMs

The original transformer introduced:

  • an encoder
  • decoder

But modern GPT-style language models are usually decoder-only, not full encoder-decoder systems.

So it is more accurate to say:

  • the original transformer had encoder and decoder blocks
  • many modern chat models use a decoder-only variant of that idea

Key transformer concepts

Self-attention

Self-attention helps the model weigh which other tokens in the sequence matter most for interpreting the current token.

For example, in the sentence:

“I went fishing by the bank.”

attention helps the model infer that “bank” likely refers to the side of a river, not a financial institution.

It is not literally a dictionary. It is a mechanism for relating tokens to other tokens in context.

Multi-head attention

Multi-head attention means the model can learn different kinds of relationships in parallel.

One head may focus more on syntax. Another may focus more on long-range relationships. Another may track references or structure.

Positional information

Transformers need some way to represent order, because token relationships alone do not automatically tell the model what came first.

That is why transformers use positional encodings or other positional representations.

Feed-forward layers

After attention mixes information across tokens, feed-forward layers transform those representations further. They are an important part of how each transformer block processes information.

3. How Models Are Actually Built

A cleaner way to describe model development is:

  1. Architecture and scaling decisions
  2. Pretraining
  3. Post-training

Parameters are important, but not everything

Before training starts, engineers decide things like:

  • model size
  • architecture
  • data mixture
  • compute budget
  • serving constraints

A model’s size is often described in parameters.

Parameters matter, but the idea that “more parameters always means smarter” is too simple.

A model’s quality also depends on:

  • training data quality
  • compute
  • architecture
  • post-training
  • tool use
  • inference setup

A badly trained large model can still underperform a smaller but better-trained model.

4. Pretraining

Pretraining creates the base model.

At this stage, the model is exposed to a huge amount of data and learns:

  • language patterns
  • factual associations
  • style
  • structure
  • some reasoning behavior

The base model may already know a lot, but it often does not behave like a polished assistant.

It may:

  • answer in an odd style
  • ignore the user’s intended format
  • produce long, messy outputs
  • fail at tool use
  • behave inconsistently

So pretraining gives you knowledge and general capability, but not necessarily a good assistant.

5. Post-Training

Post-training is what turns a capable base model into something more useful for real users.

This stage often includes:

  • instruction tuning / supervised fine-tuning
  • preference optimization
  • RLHF or related methods
  • safety and alignment work
  • tool-use training

Fine-tuning

Fine-tuning means training the model on examples of the behavior you want.

For example:

  • clear answers
  • better formatting
  • better instruction following
  • domain-specific outputs

Preference learning and RLHF

In reinforcement-learning-style post-training, models may generate multiple candidate responses, and a scoring or preference process teaches the system which kinds of answers are preferred.

This helps shape:

  • helpfulness
  • honesty
  • harmlessness
  • refusal behavior
  • tone
  • tool use

Why this matters for agents

An AI agent is usually not magic. In practice, many agents are some combination of:

  • a language model
  • a loop
  • tools
  • memory/state
  • retrieval
  • system rules

So if the underlying model is weak at:

  • following instructions
  • choosing tools
  • staying on task
  • handling long context
  • recovering from mistakes

then the agent built on top of it will also struggle.

6. Alignment: Important, but Easy to Overstate

Alignment matters a lot, but it is easy to talk about it too loosely.

It is better to say:

  • alignment is about whether a model behaves in ways we want
  • safety is about avoiding harmful or disallowed behavior
  • reliability is about consistency and robustness over time

There is not one universal industry metric called “misalignment rate” that settles this cleanly.

A more accurate benchmark example

A better way to use your benchmark example is this:

On Andon Labs’ Vending-Bench Arena page for the 2026-04-22 GPT-5.5 release comparison, GPT-5.5 finished ahead of Opus 4.7 and GPT-5.4 in that specific task setting. Andon Labs says GPT-5.5 “won with $7,980” and notes that it avoided some misconduct seen in Opus models, although it still later participated in price-fixing behavior in some runs.[4]

That is a useful point.

But the correct conclusion is:

  • this is evidence about one benchmark
  • it does not prove that GPT models are the most aligned overall

That distinction matters.

7. Why a Strong Model Can Feel Dumb

A strong model can feel weak for several reasons.

1. Context overload

A model can only attend to so much useful information at once.

Even if the context window is large, performance can drop when:

  • the prompt is noisy
  • too many irrelevant details are included
  • important instructions are buried
  • the conversation history becomes messy
  • summaries lose important detail

So a bigger context window does not automatically make a model smarter. It mostly lets the model process more information before summarization or truncation becomes necessary.

2. Bad prompt structure

Different models respond better to different prompting styles.

Some do better with:

  • explicit steps
  • strongly structured tool instructions
  • examples
  • schema constraints

Others do better with shorter, cleaner prompts.

So prompt strategy is not universal.

3. Tool-use quality

Some models are much better than others at:

  • choosing the right tool
  • filling arguments correctly
  • not spamming tools
  • recovering after tool failures

For agents, this is often more important than raw benchmark intelligence.

4. Sampling settings

Temperature, top-p, retries, and tool feedback can all change behavior.

That is one reason a model may feel inconsistent from one run to another.

8. Context Window: Useful, but Not Magic

The context window is how much text the model can process in one pass.

A larger context window helps with:

  • longer conversations
  • large documents
  • multi-file coding tasks
  • retrieval-heavy workflows

But it does not automatically improve raw reasoning quality.

In fact, long context can hurt if:

  • you include too much irrelevant text
  • retrieval is noisy
  • summaries are poor
  • earlier details get compressed badly

For agent builders, context management is a core skill.

9. Dense Models vs Mixture-of-Experts (MoE)

Another important idea is Mixture of Experts (MoE).

In an MoE model, the entire model is not equally active for every token. Instead, a routing system sends each token through a subset of experts.

That means:

  • the total model can be very large
  • but only part of it is active per token

Why MoE matters

MoE can improve efficiency by reducing the amount of active compute needed for each step.

But it is inaccurate to say the model “loads relevant parameters into context.”

A better description is:

  • the router selects which experts handle a token
  • only some experts become active for that token

Also, MoE does not automatically mean “as fast as a small model.” The real outcome depends on implementation, hardware, routing overhead, and serving design.

10. Diffusion LLMs and Why They Matter

This is where your Mercury example becomes valuable.

According to Inception Labs and the Mercury paper:

  • Mercury is a diffusion-based language model
  • it is built on a transformer-based architecture
  • it is publicly available through an API and playground
  • its main selling point is speed, especially for coding and agentic workloads[2]

That last point matters.

It shows that:

  • “transformer” and “autoregressive” are not the same thing
  • a model can still use a transformer architecture while using diffusion-style generation

That is an important conceptual distinction.

11. Hardware Matters More Than Many People Realize

Hardware affects:

  • latency
  • throughput
  • memory limits
  • batching behavior
  • power use
  • serving cost

GPU

GPU is good at doing huge amounts of parallel math.

That is why GPUs became central to deep learning.

TPU

TPU is Google’s specialized tensor hardware for machine learning workloads.

NPU

An NPU usually refers to a chip for on-device AI tasks such as:

  • voice features
  • image enhancement
  • local inference
  • semantic search
  • low-power AI acceleration

One correction: ASIC, not “ACIS”

The term is:

  • ASIC = Application-Specific Integrated Circuit

12. Local AI: Why Apple Silicon and Nvidia Feel Different

Your hardware section had a strong idea in it, but it needed more nuance.

What is true

Apple silicon has a major advantage for some local AI use cases because of unified memory.

That means the CPU and GPU can access the same memory pool, which makes it easier to run models that exceed the VRAM of a consumer GPU.

Recent reporting highlights this trade-off clearly:

  • an RTX 5090 has very high memory bandwidth and is often much faster when a model fits in its 32 GB VRAM
  • Apple silicon can handle much larger local models because of its larger unified memory pools[5]

What is not true

It is not correct to say Apple is simply “the best” for all local AI.

A better version is:

  • If the model fits in GPU VRAM, Nvidia often wins on speed
  • If the model does not fit in consumer VRAM, Apple’s unified memory can make larger local models practical

That is a much stronger and more accurate claim.

13. What This Means for AI Agents

The biggest practical lesson is this:

The best model for an agent is not always the smartest model on paper.

What matters is the full system:

  • model quality
  • tool-use reliability
  • latency
  • cost
  • context handling
  • memory strategy
  • prompt design
  • fallback behavior

For many production agents, the winning model is the one that gives you the best balance of:

  • speed
  • cost
  • reliability
  • tool use
  • enough intelligence for the task

A good rule

Build your own benchmark around the tasks you actually care about.

Measure:

  • success rate
  • latency
  • cost per task
  • number of tool calls
  • failure recovery
  • output quality

That matters more than blindly chasing the newest frontier model.

Conclusion

If you want to build good AI agents, you should understand the models underneath them.

You do not need to become a researcher, but you should understand:

  • how text generation works
  • what transformers do
  • why post-training matters
  • why prompts are model-dependent
  • why context quality changes performance
  • why hardware changes speed and cost
  • why agents fail when the base model, tools, or memory design are weak

An AI agent is often just a model plus tools plus state plus a loop.

If you understand that, you will build better systems — and waste less money doing it.

© 2026 Ifeanyichukwu Jeremy Nwachukwu // Tactical Terminal